<!DOCTYPE html>
<html lang="en" style="overflow-x:auto;overflow-y:auto;">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style>
			body{
				padding: 0;
				margin: 0;
				background: #f3f3f3;
				text-align: center;
			}
			#loading{
				position: fixed;
				left:50%;
				right: 0;;
				top: 50%;
				bottom: 0;
				width: 100px;
				height: 100px;
				margin-left: -50px;
				margin-top: -50px;
				background: #f65133;
				-webkit-animation: loader 1.2s infinite ease-in-out;
				animation: loader 1.2s infinite ease-in-out;
			}

			@-webkit-keyframes loader {
			    0% {
			        -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
			        transform: perspective(120px) rotateX(0deg) rotateY(0deg);
			    }
			    50% {
			        -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
			        transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
			    }
			    100% {
			        -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
			        transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
			    }
			}
			@keyframes loader {
			    0% {
			        -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
			        transform: perspective(120px) rotateX(0deg) rotateY(0deg);
			    }
			    50% {
			        -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
			        transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
			    }
			    100% {
			        -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
			        transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
			    }
			}
			myHero {
                    display: block;
                    background-color: white;
                    padding: 100px;
                    color:rgba(55, 55, 161, 0.281);
                    font-size: 50px;
                    font-weight:bold;
                    height: 300px;
                    line-height:300px;
                }
            </style>
		<script src="jquery.min.js"></script>
		<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
		<!--需引入的js-->
		<script>
			function callback(result) {
				alert(result);
			}

			function GetQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if (r != null) return unescape(r[2]);
				return null;
			}
			var code = GetQueryString("code");
			var miniparam = GetQueryString("miniparam");
			var minijson = JSON.parse(miniparam);
			minijson.commcode = code;
			var xhr = new XMLHttpRequest();
			xhr.open("GET", 'https://www.card5.net/aidpointsoft/wxsmallprocplugins.asq?funid=4&data=' + JSON.stringify(
				minijson));
			xhr.send();

			xhr.onreadystatechange = function() {
				//一定要加这几个条件判断,否则会执行2次
				if (xhr.readyState == 4 && xhr.status == 200 && xhr.responseText != '') {
					var data = JSON.parse(xhr.response);
					//callback(JSON.stringify(data));
					if (data.state == 8888) {
						//告诉小程序是h5页面调用后返回的数据
						data.onload_state = 'html_load';
						//返回传入时的小程序扫码的字符串,小程序重新载入时好处理
						data.scan_paramstr = minijson.scan_paramstr;
						var gotopage = minijson.gotopage;
						var goto_page = gotopage + '?psource=h5&resdata=' + JSON.stringify(data);
						//跳转小程序设置的页面
						if (minijson.redirect_type == null || minijson.redirect_type == '0')
							wx.miniProgram.redirectTo({
								url: goto_page
							})
						else if (minijson.redirect_type == '1')
							wx.miniProgram.switchTab({
								url: minijson.gotopage
							})
						else if (minijson.redirect_type == '2')
							wx.miniProgram.reLaunch({
								url: goto_page
							})
						else if (minijson.redirect_type == '3')
							wx.miniProgram.navigateBack({
								url: goto_page
							});
					} else callback('获取微信授权失败:' + data.errorMessage);
				};
			};
		</script>
	</head>
	<body>
		<!-- <myHero>正在获取微信公众号授权....</myHero> -->
		<div id="loading"></div>
	</body>
</html>
